<?php
if(isset($form['#farmer'])&& !empty($form['#farmer'])) {
    echo get_template_header_info($form['#farmer']);
}
?>
<?php
if(isset($form['#addr_id'])&& !empty($form['#addr_id'])) {
    echo get_template_header_info($form['#addr_id'], 'village');
}
?>
<div class="hp-tab-newprd">
    <?php if(!empty($_GET['farmer_id'])){?>
        <img style="margin-left: 75px;" src="<?php echo base_path()?>sites/all/themes/tweme/images/images/farmer.png"/>
    <?php }else if(!empty($_GET['addr_id'])){ ?>
        <img style="margin-left: 75px;" src="<?php echo base_path()?>sites/all/themes/tweme/images/images/village.png"/>
    <?php }?>
    <ul class="j-sw-nav">
        <?php if(!$form['#farmer'] && !$form['#addr_id']){?>
            <li class="newprd-s1 tab-li on"><a href="<?php echo base_path();?>farmer/soil_info/list">查看</a></li>
        <?php if(user_access('add soil_info')){?>
            <li class="newprd-s2 tab-li"><a href="<?php echo base_path();?>farmer/soil_info/add">添加</a></li>
        <?php }
        }else if(isset($form['#addr_id'])&& !empty($form['#addr_id'])){
            echo get_tab($form['#addr_id'],'soil_info','village');
            ?>
        <?php }else if(isset($form['#farmer'])&& !empty($form['#farmer'])){?>
            <?php echo get_tab($form['#farmer'],'soil_info'); ?>
        <?php }?>
    </ul>
    <div class="newprd-s1">
        <div class="table-div">
            <div style="height: 17px; cursor: pointer"><span style="float:right; margin-right: 20px; font-size: 14px;font-weight: bold" class="openORclose">展开搜索</span></div>
            <div class="search-div" style="display: none;margin-bottom: 10px">
                <div class="small-select"><div class="search-label">请选年份:</div><?php print render($form['year']); ?></div>
                <?php  global $user;
                $user_info = _get_user_info($user->uid);
                if ($user_info['role'] != '农户') {?>
                <?php if(empty($form['#farmer'])&&empty($form['#addr_id'])){?>
                         <?php  print _address_render_for_list($form);  ?>
                    <?php }?>
                    <div class="small-select max-big-input column" style="clear:both">
                        <div class="search-label">专项活动:</div><?php print render($form['special_activities']); ?>
                    </div>
                <div class="small-input" style="float: left; width: 200px;"><div class="search-label">送样人:</div><?php print render($form['sampler']); ?></div>
                <?php }?>
                <div class="small-select small-input" style="clear: both">
                    <div class="search-label">请选字段:</div><?php print render($form['field']); ?>
                </div>
                <div class="small-select small-input" style="clear: both">
                    <div style="float: left; width:200px"><div class="search-label">范围:</div><?php print render($form['min_number']); ?></div>
                    <?php print render($form['max_number']); ?>
                </div>

                <div class="search-submit"><?php print render($form['submit']); ?></div>
            </div>



<!--            <img class="res-search" src='--><?php //echo base_path();?><!--sites/all/themes/tweme/images/images/stats.png'>-->
            <div class="stats-div"><span>土壤信息统计结果</span></div>
            <div class="table-div">
                <div class="farmer-field" style="margin-top: 0px">
                    <div class="farmer-field-div second">
                        <span>总条目:</span>
                        <span><?php echo $form['#stat']['#count'] ; ?>条</span>
                    </div>
                    <div class="farmer-field-div second" style="clear:both">
                        <span>平均数据:</span>
                    </div>
                    <div class="farmer-field-div second" style="clear:both">
                        <span>氮(mg/L):</span>
                        <span><?php echo $form['#stat']['#avg_nitrogen']; ?></span>
                    </div>
                    <div class="farmer-field-div second">
                        <span>磷(mg/L):</span>
                        <span><?php echo $form['#stat']['#avg_phosphorus']; ?></span>
                    </div>
                    <div class="farmer-field-div second">
                        <span>钾(mg/L):</span>
                        <span><?php echo $form['#stat']['#avg_potassium']; ?></span>
                    </div>
                    <div class="farmer-field-div second">
                        <span>有机质(mg/L):</span>
                        <span><?php echo $form['#stat']['#avg_organicmatter']; ?></span>
                    </div>

                    <div class="farmer-field-div second">
                        <span>PH值:</span>
                        <span><?php echo $form['#stat']['#avg_ph'] ; ?></span>
                    </div>
                    <div class="farmer-field-div second">
                        <span>钙(mg/L):</span>
                        <span><?php echo $form['#stat']['#avg_calcium']; ?></span>
                    </div>
                    <div class="farmer-field-div second">
                        <span>镁(mg/L):</span>
                        <span><?php echo $form['#stat']['#avg_magnesium']; ?></span>
                    </div>
                    <div class="farmer-field-div second">
                        <span>硫(mg/L):</span>
                        <span><?php echo $form['#stat']['#avg_sulfur']; ?></span>
                    </div>
                    <div class="farmer-field-div second">
                        <span>锌(mg/L):</span>
                        <span><?php echo $form['#stat']['#avg_zinc']; ?></span>
                    </div>

                    <div class="farmer-field-div second">
                        <span>铜(mg/L):</span>
                        <span><?php echo $form['#stat']['#avg_copper']; ?></span>
                    </div>
                    <div class="farmer-field-div second">
                        <span>铁(mg/L):</span>
                        <span><?php echo $form['#stat']['#avg_iron']; ?></span>
                    </div>
                    <div class="farmer-field-div second">
                        <span>硼(mg/L):</span>
                        <span><?php echo $form['#stat']['#avg_boron']; ?></span>
                    </div>
                    <div class="farmer-field-div second">
                        <span>锰(mg/L):</span>
                        <span><?php echo $form['#stat']['#avg_manganese']; ?></span>
                    </div>
                </div>
                <div style="clear:both"></div>
                <?php if(isset($form['#farmer'])&& !empty($form['#farmer'])){?>
                    <ul class="table-ul-li"  style="float: right">
<!--                        <li><a href="--><?php //echo base_path(); ?><!--farmer/soil_info/list?farmer_id=--><?php //echo $form['#farmer']?><!--" class="selected">列表</a></li>-->
                        <?php if(user_access('add soil_info')){?>
<!--                            <li>|</li>-->
                            <li><a href="<?php echo base_path(); ?>farmer/soil_info/add?farmer_id=<?php echo $form['#farmer']?>"class="btn btn-primary">添加</a></li>
                        <?php }?>
                    </ul>
                <?php }?>
                <?php if(isset($_GET['addr_id'])&& !empty($_GET['addr_id'])){?>
                    <ul class="table-ul-li"  style="float: right">
<!--                        <li><a href="--><?php //echo base_path(); ?><!--farmer/soil_info/list?addr_id=--><?php //echo $_GET['addr_id']?><!--" class="selected">列表</a></li>-->
                        <?php if(user_access('add soil_info')){?>
<!--                            <li>|</li>-->
                            <li><a href="<?php echo base_path(); ?>farmer/soil_info/add?addr_id=<?php echo $_GET['addr_id']?>"class="btn btn-primary">添加</a></li>
                        <?php }?>
                    </ul>
                <?php }?>
            </div>



            <img class="res-search" src='<?php echo base_path();?>sites/all/themes/tweme/images/images/res.png'>
            <div class="table-div">
                <?php print render($form['table']); ?>
            </div>
     </div>
    </div>
</div>
<?php print drupal_render_children($form); ?>
